package com.itestor.iptv.modules.common.vo;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Vector;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionBindingListener;

import com.itestor.iptv.modules.common.utils.CommonConstant;

public class UserCount implements HttpSessionBindingListener{

	private int id;
	private String username;
	private String password;
	private String realname;
	private String rolename;
	private String phone;
	private String mobile;
	private String email;
	private String description;
	private Date lastUpdateTs;
	private String lastUpdateBy;
	private Integer roleGroupId;
	private static Integer num = 0;

	private Collection<String> rolenames = new ArrayList<String>();

	private String customer;
	
	private Collection<String> accountnames = new ArrayList<String>();;
	private Map<Integer, Collection<Integer>> devices = new LinkedHashMap<Integer, Collection<Integer>>();
	private Map<Integer, Collection<Integer>> monitorflows = new LinkedHashMap<Integer, Collection<Integer>>();

	private ServletContext application = null;

//	public UserCount(ServletContext application){
//	    super();
//	    if (application ==null)
//	        throw new IllegalArgumentException("Null application is not accept.");
//	    this.application = application;
//	}
	
	public String getCustomer() {
		return customer;
	}

	public void setCustomer(String customer) {
		this.customer = customer;
	}

	public Collection<String> getAccountnames() {
		return accountnames;
	}

	public void setAccountnames(Collection<String> accountnames) {
		this.accountnames = accountnames;
	}

	public Map<Integer, Collection<Integer>> getDevices() {
		return devices;
	}

	public void setDevices(Map<Integer, Collection<Integer>> devices) {
		this.devices = devices;
	}

	public Map<Integer, Collection<Integer>> getMonitorflows() {
		return monitorflows;
	}

	public void setMonitorflows(Map<Integer, Collection<Integer>> monitorflows) {
		this.monitorflows = monitorflows;
	}

	public Collection<String> getRolenames() {
		return rolenames;
	}

	public void setRolenames(Collection<String> rolenames) {
		this.rolenames = rolenames;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getRealname() {
		return realname;
	}

	public void setRealname(String realname) {
		this.realname = realname;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Date getLastUpdateTs() {
		return lastUpdateTs;
	}

	public void setLastUpdateTs(Date lastUpdateTs) {
		this.lastUpdateTs = lastUpdateTs;
	}

	public String getLastUpdateBy() {
		return lastUpdateBy;
	}

	public void setLastUpdateBy(String lastUpdateBy) {
		this.lastUpdateBy = lastUpdateBy;
	}

	private String department;

	public String getDepartment() {
		return department;
	}

	public void setDepartment(String department) {
		this.department = department;
	}

    public String getRolename() {
        return rolename;
    }

    public void setRolename(String pRolename) {
        rolename = pRolename;
    }

    public Integer getRoleGroupId() {
        return roleGroupId;
    }

    public void setRoleGroupId(Integer pRoleGroupId) {
        roleGroupId = pRoleGroupId;
    }

    public void valueBound(HttpSessionBindingEvent pArg0) {
//        Vector activeSessions = (Vector) application.getAttribute("activeSessions");
//        if (activeSessions == null)
//        {
//            activeSessions = new Vector();
//        }
//
//        User sessionUser = (User)pArg0.getSession().getAttribute(CommonConstant.SESSION_ATTR_USER);
//        if (sessionUser != null)
//        {
//            activeSessions.add(pArg0.getSession());
//        }
//        application.setAttribute("activeSessions",activeSessions);
        num++;
        System.out.println("valueBound--current:"+num);
    }

    public void valueUnbound(HttpSessionBindingEvent pArg0) {
        num--;
        System.out.println("valueUnbound--current:"+num);        
    }
    
}
